package com.liuhao.ssm.controller;

import com.liuhao.ssm.domain.SysLog;
import com.liuhao.ssm.service.intf.SysLogService;
import com.liuhao.ssm.util.PageUtils;
import com.liuhao.ssm.util.Query;
import com.liuhao.ssm.util.ResultData;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by liuHao on 17-6-9.
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController extends BaseController{
    @Autowired
    private SysLogService sysLogService;

    @ResponseBody
    @RequestMapping("/list")
    @RequiresPermissions("sys:log:list")
    public ResultData list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<SysLog> sysList = sysLogService.getSysLogList(query);
        int total = sysLogService.getSysLogListCount();

        PageUtils pageUtil = new PageUtils(sysList, total, query.getLimit(), query.getPage());

        return ResultData.ok().put("page", pageUtil);
    }
}
